<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>RF22: RF22Datagram.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">RF22
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">RF22Datagram.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// RF22Datagram.h</span>
<a name="l00002"></a>00002 <span class="comment">// Author: Mike McCauley (mikem@open.com.au)</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright (C) 2011 Mike McCauley</span>
<a name="l00004"></a>00004 <span class="comment">// $Id: RF22Datagram.h,v 1.3 2011/02/15 01:18:03 mikem Exp $</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="preprocessor">#ifndef RF22Datagram_h</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span><span class="preprocessor">#define RF22Datagram_h</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;RF22.h&gt;</span>
<a name="l00010"></a>00010 <span class="comment"></span>
<a name="l00011"></a>00011 <span class="comment">/////////////////////////////////////////////////////////////////////</span>
<a name="l00012"></a>00012 <span class="comment">/// \class RF22Datagram RF22Datagram.h &lt;RF22Datagram.h&gt;</span>
<a name="l00013"></a>00013 <span class="comment">/// \brief RF22 subclass for addressed, unreliable messages</span>
<a name="l00014"></a>00014 <span class="comment">///</span>
<a name="l00015"></a>00015 <span class="comment">/// Extends RF22 to define addressed, unreliable datagrams.</span>
<a name="l00016"></a>00016 <span class="comment">/// Every node has an 8 bit address (defaults to 0).</span>
<a name="l00017"></a>00017 <span class="comment">/// Addresses (DEST and SRC) are 8 bit integers with an address of RF22_BROADCAST_ADDRESS (0xff) </span>
<a name="l00018"></a>00018 <span class="comment">/// reserved for broadcast.</span>
<a name="l00019"></a>00019 <span class="comment">///</span>
<a name="l00020"></a>00020 <span class="comment">/// Part of the Arduino RF22 library for operating with HopeRF RF22 compatible transceivers </span>
<a name="l00021"></a>00021 <span class="comment">/// (see http://www.hoperf.com).</span>
<a name="l00022"></a><a class="code" href="classRF22Datagram.html">00022</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classRF22Datagram.html" title="RF22 subclass for addressed, unreliable messages.">RF22Datagram</a> : <span class="keyword">public</span> <a class="code" href="classRF22.html" title="Send and receive unaddressed, unreliable datagrams.">RF22</a>
<a name="l00023"></a>00023 {
<a name="l00024"></a>00024 <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00025"></a>00025 <span class="comment">    /// Constructor. </span>
<a name="l00026"></a>00026 <span class="comment">    /// \param[in] thisAddress The address to assign to this node. Defaults to 0</span>
<a name="l00027"></a>00027 <span class="comment">    /// \param[in] slaveSelectPin the Arduino pin number of the output to use to select the RF22 before</span>
<a name="l00028"></a>00028 <span class="comment">    /// accessing it</span>
<a name="l00029"></a>00029 <span class="comment">    /// \param[in] interrupt The interrupt number to use. Default is interrupt 0 (Arduino input pin 2)</span>
<a name="l00030"></a>00030 <span class="comment"></span>    <a class="code" href="classRF22Datagram.html#a284ef536b2abcccff721e08ad53d103a">RF22Datagram</a>(uint8_t thisAddress = 0, uint8_t slaveSelectPin = 10, uint8_t interrupt = 0);
<a name="l00031"></a>00031 <span class="comment"></span>
<a name="l00032"></a>00032 <span class="comment">    /// Initialises this instance and the radio module connected to it.</span>
<a name="l00033"></a>00033 <span class="comment">    /// Overrides the init() function in RF22</span>
<a name="l00034"></a>00034 <span class="comment"></span>    <span class="keywordtype">boolean</span> <a class="code" href="classRF22Datagram.html#a7e9eb654f8e8be094c5f2c0531218531">init</a>();
<a name="l00035"></a>00035 <span class="comment"></span>
<a name="l00036"></a>00036 <span class="comment">    /// Sets the address of this node. Defaults to 0. </span>
<a name="l00037"></a>00037 <span class="comment">    /// This will be used to set the FROM address of all messages sent by this node.</span>
<a name="l00038"></a>00038 <span class="comment">    /// If all the nodes leave the address unset (ie 0),</span>
<a name="l00039"></a>00039 <span class="comment">    /// In a conventional multinode system, all nodes will have a unique address </span>
<a name="l00040"></a>00040 <span class="comment">    /// (which you could store in EEPROM).</span>
<a name="l00041"></a>00041 <span class="comment">    /// \param[in] thisAddress The address of this node</span>
<a name="l00042"></a>00042 <span class="comment"></span>    <span class="keywordtype">void</span> <a class="code" href="classRF22Datagram.html#ab230f3306fa4fdeb218ac34b728cb3d2">setThisAddress</a>(uint8_t thisAddress);
<a name="l00043"></a>00043 <span class="comment"></span>
<a name="l00044"></a>00044 <span class="comment">    /// Sends a message to the node(s) with the given address</span>
<a name="l00045"></a>00045 <span class="comment">    /// RF22_BROADCAST_ADDRESS is a valid address which will cause the message</span>
<a name="l00046"></a>00046 <span class="comment">    /// to be accepted by all RF22Datagram nodes within range.</span>
<a name="l00047"></a>00047 <span class="comment">    /// \param[in] buf Pointer to the binary message to send</span>
<a name="l00048"></a>00048 <span class="comment">    /// \param[in] len Number of octets to send</span>
<a name="l00049"></a>00049 <span class="comment">    /// \param[in] address The address to send the message to.</span>
<a name="l00050"></a>00050 <span class="comment">    /// \return true if the message was transmitted.</span>
<a name="l00051"></a>00051 <span class="comment"></span>    <span class="keywordtype">boolean</span> <a class="code" href="classRF22Datagram.html#a316535aeb1cb389b593df5f8f1f38983">sendto</a>(uint8_t* buf, uint8_t len, uint8_t address);
<a name="l00052"></a>00052 <span class="comment"></span>
<a name="l00053"></a>00053 <span class="comment">    /// Turns the receiver on if it not already on.</span>
<a name="l00054"></a>00054 <span class="comment">    /// If there is a valid message available for this node, copy it to buf and return true</span>
<a name="l00055"></a>00055 <span class="comment">    /// The SRC address is placed in *from if present and not NULL.</span>
<a name="l00056"></a>00056 <span class="comment">    /// The DEST address is placed in *to if present and not NULL.</span>
<a name="l00057"></a>00057 <span class="comment">    /// If a message is copied, *len is set to the length.</span>
<a name="l00058"></a>00058 <span class="comment">    /// You should be sure to call this function frequently enough to not miss any messages</span>
<a name="l00059"></a>00059 <span class="comment">    /// It is recommended that you call it in your main loop.</span>
<a name="l00060"></a>00060 <span class="comment">    /// \param[in] buf Location to copy the received message</span>
<a name="l00061"></a>00061 <span class="comment">    /// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied.</span>
<a name="l00062"></a>00062 <span class="comment">    /// \param[in] from If present and not NULL, the referenced uint8_t will be set to the FROM address</span>
<a name="l00063"></a>00063 <span class="comment">    /// \param[in] to If present and not NULL, the referenced uint8_t will be set to the TO address</span>
<a name="l00064"></a>00064 <span class="comment">    /// \param[in] id If present and not NULL, the referenced uint8_t will be set to the ID</span>
<a name="l00065"></a>00065 <span class="comment">    /// \param[in] flags If present and not NULL, the referenced uint8_t will be set to the FLAGS</span>
<a name="l00066"></a>00066 <span class="comment">    /// (not just those addressed to this node).</span>
<a name="l00067"></a>00067 <span class="comment">    /// \return true if a valid message was copied to buf</span>
<a name="l00068"></a>00068 <span class="comment"></span>    <span class="keywordtype">boolean</span> <a class="code" href="classRF22Datagram.html#ab545144cb8529f5b5ef0dcb77a252eef">recvfrom</a>(uint8_t* buf, uint8_t* len, uint8_t* from = NULL, uint8_t* to = NULL, uint8_t* <span class="keywordtype">id</span> = NULL, uint8_t* flags = NULL);
<a name="l00069"></a>00069 
<a name="l00070"></a>00070 <span class="keyword">protected</span>:<span class="comment"></span>
<a name="l00071"></a>00071 <span class="comment">    /// The address of this node. Defaults to 0.</span>
<a name="l00072"></a><a class="code" href="classRF22Datagram.html#a831ccec7d05b864cc3618f9c21894f17">00072</a> <span class="comment"></span>    uint8_t <a class="code" href="classRF22Datagram.html#a831ccec7d05b864cc3618f9c21894f17" title="The address of this node. Defaults to 0.">_thisAddress</a>;
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 };
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>


<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
